#include<stdio.h>
#include<windows.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#pragma warning(disable:4996)

int main()
{
	int num1, num2, min;
	int i, maxfactor;
	scanf("%d %d", &num1, &num2);
	min = MIN(num1, num2);
	for (i = 1; i <= min; i++)
	{
		if (num1%i == 0 && num2%i == 0){
			maxfactor = i;
		}
	}
	//printf("%d\n", min);
	printf("%d\n", maxfactor);
	system("pause");
	return 0;	
}